class BlogPost
  include Mongoid::Document
  field :title, type: String
  field :content, type: String
  
  validates_length_of :title ,minimum: 6,maximum: 20,message: "wrong length of title"

  before_create :check_title
  validate :title_length

def check_title
  @temp_title = self.title
end

def title_length
  false if self.title != @temp_title
end

  embeds_many :comments
end